package me.qixiaobo.tran.core;


import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
import me.qixiaobo.enums.BaseEnum;

@Slf4j
public enum FieldTranStrategy implements TranStrategy {

    /**
     * 通过枚举类
     */
    FROM_ENUM() {
        @Override
        public String handle(String key, JSONObject jsonObject, Class<? extends BaseEnum> baseEnum) {
            log.info("枚举-----打印日志------{}", baseEnum.getName());
            // BaseEnum.getDescByCode(key, baseEnum);
            return jsonObject.getStr(key);
        }
    },

    /**
     * 通过json字符串
     */
    FROM_JSON() {
        @Override
        public String handle(String key, JSONObject jsonObject, Class<? extends BaseEnum> baseEnum) {
            log.info("json字符串-----打印日志------{}", jsonObject.toString());
            return jsonObject.getStr(key);
        }
    }
}
